﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using SlamDunk.CMS.Model.DataModel;

namespace SlamDunk.CMS.Model.ViewModel
{
    /// <summary>
    /// MasterScoreLine视图模型类
    /// </summary>
    [Serializable]
    public class MasterScoreLineView
    {
        #region 01.属性——Id
        /// <summary>
        /// 属性——Id
        /// </summary>
        public int Id { get; set; }
        #endregion

        #region 02.属性——Province
        /// <summary>
        /// 属性——Province
        /// </summary>
        public string Province { get; set; }
        #endregion

        #region 03.属性——Year
        /// <summary>
        /// 属性——Year
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Range(0, 100000, ErrorMessage = "数字过大")]
        [DisplayName("年份")]
        public int Year { get; set; }
        #endregion

        #region 04.属性——Major
        /// <summary>
        /// 属性——Major
        /// </summary>
        /// <summary>
        /// 属性——Major
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [StringLength(32, ErrorMessage = "内容过长")]
        [DisplayName("专业")]
        public string Major { get; set; }
        #endregion

        #region 05.属性——Category
        /// <summary>
        /// 属性——Category
        /// 1统招，2联考
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [DisplayName("类别")]
        [Range(1, 2, ErrorMessage = "参数有误")]
        public int Category { get; set; }
        #endregion

        #region 05.属性——CategoryName
        /// <summary>
        /// 属性——CategoryName
        /// 1统招，2联考
        /// </summary>
        [DisplayName("类别")]
        public string CategoryName { get; set; }
        #endregion

        #region 06.属性——SumScore
        /// <summary>
        /// 属性——SumScore
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Range(0, 1000, ErrorMessage = "数字过大")]
        [DisplayName("总分")]
        public int SumScore { get; set; }
        #endregion

        #region 07.属性——PoliticsEnglish
        /// <summary>
        /// 属性——PoliticsEnglish
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Range(0, 1000, ErrorMessage = "数字过大")]
        [DisplayName("政治/外语")]
        public int PoliticsEnglish { get; set; }
        #endregion

        #region 08.属性——BusiCompre
        /// <summary>
        /// 属性——BusiCompre
        /// </summary>
        [Required(ErrorMessage = "必填")]
        [RegularExpression(@"\d+", ErrorMessage = "必须是数字")]
        [Range(0, 1000, ErrorMessage = "数字过大")]
        [DisplayName("业务课/综合能力")]
        public int BusiCompre { get; set; }
        #endregion

        #region 09.属性——AdmitCount
        /// <summary>
        /// 属性——AdmitCount
        /// </summary>
        public int? AdmitCount { get; set; }
        #endregion

        #region 10.属性——AddTime
        /// <summary>
        /// 属性——AddTime
        /// </summary>
        public string AddTime { get; set; }
        #endregion

        #region 11.方法——转换为数据模型
        /// <summary>
        /// 转换为数据模型
        /// </summary>
        /// <returns>MasterScoreLine数据模型对象</returns>
        public MasterScoreLine ToDataModel()
        {
            return new MasterScoreLine()
            {
                Id = this.Id,
                Province = this.Province,
                Year = this.Year,
                Major = this.Major,
                Category = this.Category,
                SumScore = this.SumScore,
                PoliticsEnglish = this.PoliticsEnglish,
                BusiCompre = this.BusiCompre,
                AdmitCount = this.AdmitCount,
                DelFlag = false,
                AddTime = DateTime.Now
            };
        }
        #endregion
    }
}
